package com.fedming.bottomnavigationdemo.Call;

import android.util.Log;

import org.java_websocket.client.WebSocketClient;
import org.java_websocket.drafts.Draft_6455;
import org.java_websocket.handshake.ServerHandshake;

import java.net.URI;

import javax.net.ssl.SSLParameters;

public class JWebSocketClient extends WebSocketClient {
    @Override
    protected void onSetSSLParameters(SSLParameters sslParameters) {
//        super.onSetSSLParameters(sslParameters);
    }

    public JWebSocketClient(URI serverUri) {
        super(serverUri, new Draft_6455());
    }

    @Override
    public void onOpen(ServerHandshake handshakedata) {
        Log.v("JWebSocketClient", "连接服务器成功！");
    }

    @Override  //必须要重写这个onMessage函数
    public void onMessage(String message) {
        Log.v("JWebSocketClient", "onMessage()");
    }

    @Override
    public void onClose(int code, String reason, boolean remote) {
        Log.v("JWebSocketClient", "关闭socket连接");
        //或者在这里执行重连接
    }

    @Override
    public void onError(Exception ex) {
        Log.e("JWebSocketClient", ex.toString());

    }
}
